﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IM.Easy.Infrastructure.Constants
{
    /// <summary>
    ///组织类型枚举的类
    /// </summary>
    public class OrgTypeConstant
    {
        /// <summary>
        /// 集团类型
        /// </summary>
        public static readonly string Group = "GROUP";

        /// <summary>
        /// 公司类型
        /// </summary>
        public static readonly string Company = "COMPANY";

        /// <summary>
        /// 部门类型
        /// </summary>
        public static readonly string Dept = "DEPT";

        /// <summary>
        /// 团队类型
        /// </summary>
        public static readonly string Team = "TEAM";

        /// <summary>
        /// 虚拟组织类型
        /// </summary>
        public static readonly string Virtual = "VIRTUAL";


        private static readonly Dictionary<string, List<string>> subTypeMapping = new()
        {
        { "GROUP", new List<string> { "COMPANY", "VIRTUAL" } },
        { "COMPANY", new List<string> { "DEPT", "VIRTUAL" } },
        { "DEPT", new List<string> { "DEPT", "TEAM", "VIRTUAL" } },
        { "TEAM", new List<string> { "TEAM", "VIRTUAL" } },
        { "VIRTUAL", new List<string>{  "COMPANY", "DEPT", "TEAM", "VIRTUAL" } }
       };

        /// <summary>
        /// 根据组织类型字符串获取描述
        /// </summary>
        /// <param name="orgType">组织类型字符串</param>
        /// <returns>组织类型描述</returns>
        public static string GetDescription(string orgType)
        {
            switch (orgType)
            {
                case nameof(Group):
                    return "集团";
                case nameof(Company):
                    return "公司";
                case nameof(Dept):
                    return "部门";
                case nameof(Team):
                    return "团队";
                case nameof(Virtual):
                    return "虚拟组织";
                default:
                    return string.Empty;
            }
        }

        public static List<string> GetSubOrgTypes(string orgType)
        {
            var subTypeValues = subTypeMapping.TryGetValue(orgType, out List<string>? value) ? value : [];
            return subTypeValues;
        }


    }
}
